package com.example.demo.controller;

import com.example.demo.pojo.Result;
import com.example.demo.pojo.dto.DeleteDto;
import com.example.demo.pojo.dto.add.StudentAddDto;
import com.example.demo.pojo.dto.update.StudentUpdateDto;
import com.example.demo.pojo.vo.PageVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;


import com.github.pagehelper.PageInfo;
import com.example.demo.entity.Student;
import com.example.demo.service.IStudentService;
import com.example.demo.pojo.query.StudentQuery;
import com.example.demo.pojo.vo.StudentVo;
import io.swagger.annotations.*;

/**
 * <p>
 * 学员信息表 前端控制器
 * </p>
 *
 * @author tds
 * @since 2021-09-30
 */
@RestController
@Api(value = "学员信息表接口")
@RequestMapping("/demo/student")
public class StudentController {

   @Autowired
   private IStudentService studentService;

   @ApiOperation(value = "获取学员信息表列表",notes="获取学员信息表列表")
   @PostMapping("/queryPage")
   public Result<PageVo<StudentVo>> queryPage(@ApiParam @RequestBody StudentQuery query)  {
      return Result.success(studentService.queryPage(query));
   }

   @ApiOperation(value = "新增",notes="新增")
   @PostMapping("/add")
   public Result add(@ApiParam @RequestBody StudentAddDto addDto)  {
      studentService.save(addDto);
      return Result.success();
   }

   @ApiOperation(value = "修改",notes="根据id修改")
   @PostMapping("/update")
   public Result update(@ApiParam @RequestBody StudentUpdateDto updateDto)  {
      studentService.update(updateDto);
      return Result.success();
   }

   @ApiOperation(value = "删除多条数据",notes="删除多条数据")
   @PostMapping("/deleteBatch")
   public Result deleteBatch(@ApiParam @RequestBody DeleteDto deleteDto)  {
      studentService.delete(deleteDto);
      return Result.success();
   }



}
